﻿// JScript 文件

//此文件是基础模块内的导入教师功能
//导入Excel
function CheckUplaod()
{
//    alert(2);
//    if(document.getElementById("txtUpload").value.Trim()=="")
//    {
//        showMassgeBox("系统提示","请选择导入的Excel文件!",1,null);
//        return false;
//    }
//    return true;
}



function ImportExcel()
{
   var sheetSelect=document.getElementById("sheetSelect");
   var codeSelect=document.getElementById("codeSelect");
   var nameSelect=document.getElementById("nameSelect");
   //alert(1);
   
   if(sheetSelect.value.Trim()=="")
   {
       showNoticMsg("sheetSelect","请选择Sheet")
       return;
   }
   
   
   if(codeSelect.value.Trim()=="")
   {
       showNoticMsg("codeSelect","请选择编号对应列")
       return;
   }
   
   if(nameSelect.value.Trim()=="")
   {
        showNoticMsg("nameSelect","请选择姓名对应列")
        return;
   }
   PageMethods.ImportExcel(sheetSelect.value,codeSelect.value,nameSelect.value,function(result){
    if(result==1){
      CloseForm();
      Bind();
      showMassgeBox("提示","导入成功!",1,null);
    }else
    {
    
      showMassgeBox("提示","导入失败!",1,null);
    
    }
   
   },function(err)
   {
      showMassgeBox("错误",MSG_ERROR_MESSAGE,2,null);
   });
}


///选择样表下拉列表onchang处理程序
function ChangHandle()
{
     oSelect=document.getElementById("sheetSelect");
     if(oSelect.options.length>0)
     {
        PageMethods.GetColList(oSelect.value,function(result){
         var s1=document.getElementById("codeSelect");
         var s2=document.getElementById("nameSelect");
          s1.options.length=0;
          s2.options.length=0;
          for(var i=0;i<result.length;i++)
          {
	        var oOption = document.createElement("OPTION");
	        var oOption1 = document.createElement("OPTION");
	        oOption.text=result[i];
	        oOption1.text=result[i];
            oOption.value=result[i];
            oOption1.value=result[i];
            s1.options.add(oOption);
            s2.options.add(oOption1);
          }
        },function(err){
        
        })
     }
}

function ImportHandle()
{

 ShowPopForm("ImportForm", "ImportFormTitle", "Excel导入");
 document.getElementById("upload").innerHTML='<input id="File1"  name="File1" type="file" style="width:250px" />';

}

function CloseForm()
{
   ClosePopForm("ImportForm");
   document.getElementById("upload").innerHTML="";
   document.getElementById("row1").style.display="none";
   document.getElementById("row2").style.display="none";
   document.getElementById("row3").style.display="block";
   document.getElementById("sheetSelect").options.length=0;
   document.getElementById("codeSelect").options.length=0;
   document.getElementById("nameSelect").options.length=0;
}

function CancelImport()
{

      CloseForm();
//      PageMethods.DelTemp(function(result){
//      
//      
//      },function(err){
//      
//      
//      
//      
//      })


}